﻿using UnityEngine;
using System.Collections.Generic;
using NetWork;
using ProtoBuf.Message;
namespace Room
{
    public class RoomNetField : RoomNetBase
    {
        private RoomField roomField
        {
            get { return roomBase as RoomField; }
        }

        private Queue<SideResource> resAppearQueue = new Queue<SideResource>();
        private Queue<SideResource> resDisppearQueue = new Queue<SideResource>();

        #region 状态驱动

        public override void Enter()
        {
            base.Enter();

        }
        public override void Leave()
        {
            base.Leave();
            resAppearQueue.Clear();
            resDisppearQueue.Clear();

            playerSideQueue.Clear();
        }

        public override void Pause()
        {
            base.Pause();
        }

        public override void Resume()
        {
            base.Resume();

            //SendCSCurrentPosition(null);
            CheckResOrMonster();//重连后检查一遍资源
            UI.UIFieldRunMap.RefreshPage();
        }
        public override void Tick()
        {
            base.Tick();

            while (resDisppearQueue.Count > 0)
            {
                SolveDisappearResource(resDisppearQueue.Dequeue());
            }
            while (resAppearQueue.Count > 0)
            {
                SolveAddResource(resAppearQueue.Dequeue());
            }

            while (playerSideQueue.Count > 0)
            {
                SolveUpdateMovePlayer(playerSideQueue.Dequeue());
            }
        }
        #endregion


        #region 消息注册
        public override void RegistSocketHandler()
        {
            base.RegistSocketHandler();

            #region 野外
            NetAPI.RegistSocketHandler(OpDefine.SCFieldResourceInfo, SCFieldResourceInfo);
            NetAPI.RegistSocketHandler(OpDefine.SCFieldGetResource, SCFieldGetResource);
            NetAPI.RegistSocketHandler(OpDefine.SCFieldPlayerState, SCFieldPlayerState);
            NetAPI.RegistSocketHandler(OpDefine.SCFieldResourceStartGather, SCFieldResourceStartGather);
            NetAPI.RegistSocketHandler(OpDefine.SCSidePvpFightResult, SCSidePvpFightResult);
            NetAPI.RegistSocketHandler(OpDefine.SCSidePushState, SCSidePushState);

            NetAPI.RegistSocketHandler(OpDefine.SCGetLineInfo, SCGetLineInfo);

            NetAPI.RegistSocketHandler(OpDefine.SCResurrenttion, SCResurrenttion);
            NetAPI.RegistSocketHandler(OpDefine.SCTransfer2Safe, SCTransfer2Safe);
            NetAPI.RegistSocketHandler(OpDefine.SCTransferLine, SCTransferLine);
            NetAPI.RegistSocketHandler(OpDefine.SCSideResourceCheck, SCSideResourceCheck);

            NetAPI.RegistSocketHandler(OpDefine.SCSideMonster, SCSideMonster);
            NetAPI.RegistSocketHandler(OpDefine.SCSideMonsterCheck, SCSideMonsterCheck);
            NetAPI.RegistSocketHandler(OpDefine.SCSidePveFightStart, SCSidePveFightStart);

            NetAPI.RegistSocketHandler(OpDefine.SCSideBoss, SCSideBoss);
            NetAPI.RegistSocketHandler(OpDefine.SCSideBossCheck, SCSideBossCheck);
            NetAPI.RegistSocketHandler(OpDefine.SCSidePveBossFightStart, SCSidePveBossFightStart);
            NetAPI.RegistSocketHandler(OpDefine.SCSideBossCountdown, SCSideBossCountdown);
            #endregion

            #region 网速
            NetAPI.RegistSocketHandler(OpDefine.SCPingTcp, SCPingTcp);
            #endregion

            #region 组队信息
            NetAPI.RegistSocketHandler(OpDefine.SCTeamCreateAndInvite, SCTeamCreateAndInvite);
            NetAPI.RegistSocketHandler(OpDefine.SCQueryTeam, SCQueryTeam);
            NetAPI.RegistSocketHandler(OpDefine.SCJoinTeam, SCJoinTeam);
            NetAPI.RegistSocketHandler(OpDefine.SCExitTeam, SCExitTeam);
            NetAPI.RegistSocketHandler(OpDefine.SCDisbandTeam, SCDisbandTeam);
            NetAPI.RegistSocketHandler(OpDefine.SCTeamKick, SCTeamKick);
            NetAPI.RegistSocketHandler(OpDefine.SCCheckTeam, SCCheckTeam);
            NetAPI.RegistSocketHandler(OpDefine.SCQueryTeamTick, SCQueryTeamTick);
            #endregion

            NetAPI.RegistSocketHandler(OpDefine.SCPublicMessage, SCPublicMessage);
        }

        public override void UnRegistSocketHandler()
        {
            base.UnRegistSocketHandler();

            #region 野外
            NetAPI.UnregisterSocketHandler(OpDefine.SCFieldResourceInfo, SCFieldResourceInfo);
            NetAPI.UnregisterSocketHandler(OpDefine.SCFieldGetResource, SCFieldGetResource);
            NetAPI.UnregisterSocketHandler(OpDefine.SCFieldPlayerState, SCFieldPlayerState);
            NetAPI.UnregisterSocketHandler(OpDefine.SCFieldResourceStartGather, SCFieldResourceStartGather);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSidePvpFightResult, SCSidePvpFightResult);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSidePushState, SCSidePushState);

            NetAPI.UnregisterSocketHandler(OpDefine.SCGetLineInfo, SCGetLineInfo);

            NetAPI.UnregisterSocketHandler(OpDefine.SCResurrenttion, SCResurrenttion);
            NetAPI.UnregisterSocketHandler(OpDefine.SCTransfer2Safe, SCTransfer2Safe);
            NetAPI.UnregisterSocketHandler(OpDefine.SCTransferLine, SCTransferLine);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSideResourceCheck, SCSideResourceCheck);

            NetAPI.UnregisterSocketHandler(OpDefine.SCSideMonster, SCSideMonster);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSideMonsterCheck, SCSideMonsterCheck);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSidePveFightStart, SCSidePveFightStart);

            NetAPI.UnregisterSocketHandler(OpDefine.SCSideBoss, SCSideBoss);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSideBossCheck, SCSideBossCheck);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSidePveBossFightStart, SCSidePveBossFightStart);
            NetAPI.UnregisterSocketHandler(OpDefine.SCSideBossCountdown, SCSideBossCountdown);
            #endregion

            #region 网速
            NetAPI.UnregisterSocketHandler(OpDefine.SCPingTcp, SCPingTcp);
            #endregion

            NetAPI.UnregisterSocketHandler(OpDefine.SCTeamCreateAndInvite, SCTeamCreateAndInvite);
            NetAPI.UnregisterSocketHandler(OpDefine.SCQueryTeam, SCQueryTeam);
            NetAPI.UnregisterSocketHandler(OpDefine.SCJoinTeam, SCJoinTeam);
            NetAPI.UnregisterSocketHandler(OpDefine.SCExitTeam, SCExitTeam);
            NetAPI.UnregisterSocketHandler(OpDefine.SCDisbandTeam, SCDisbandTeam);
            NetAPI.UnregisterSocketHandler(OpDefine.SCTeamKick, SCTeamKick);
            NetAPI.UnregisterSocketHandler(OpDefine.SCCheckTeam, SCCheckTeam);
            NetAPI.UnregisterSocketHandler(OpDefine.SCQueryTeamTick, SCQueryTeamTick);

            NetAPI.UnregisterSocketHandler(OpDefine.SCPublicMessage, SCPublicMessage);
        }
        #endregion


        #region 资源检查
        const float checkDis = 20f;
        void CheckResOrMonster()
        {
            var self = roomBase.charactorManager.GetSelfCharactor();
            if(self!=null)
            {
                foreach (var kvp in roomBase.charactorManager.GetCharactors())
                {
                    var resOrMonster = kvp.Value;

                    if (resOrMonster.type == CharactorType.Mine ||
                        resOrMonster.type == CharactorType.Fish ||
                        resOrMonster.type == CharactorType.ServerMonster ||
                        resOrMonster.type == CharactorType.FieldBoss)
                    {

                        var var0 = new Vector2(self.transform.position.x, self.transform.position.z);
                        var var1 = new Vector2(resOrMonster.transform.position.x, resOrMonster.transform.position.z);
                        var dis = Vector2.Distance(var0, var1);
                        if (dis <= checkDis)
                        {
                            if (resOrMonster.type == CharactorType.FieldBoss)
                            {
                                SendCheckPveBoss(resOrMonster.name);
                            }
                            else if (resOrMonster.type == CharactorType.ServerMonster)
                            {
                                SendCheckPveMonster(resOrMonster.name);
                            }
                            else if (resOrMonster.type == CharactorType.Fish ||
                                resOrMonster.type == CharactorType.Mine)
                            {
                                var pos = resOrMonster.name.Split(new char[1] { '@' });
                                SendResourceCheck(pos[1]);
                            }
                        }
                    }
                }
            }
        }
        #endregion

        #region Callback
        protected override void SCCurrentPosition(object obj)
        {
            base.SCCurrentPosition(obj);
            var charactor = roomBase.charactorManager.GetSelfCharactor();

            SCCurrentPosition msg = obj as SCCurrentPosition;

            if (msg != null && msg.self != null && msg.self.info != null && msg.self.info.playerSide != null)
            {
                var ai = charactor.ai as RCAIActor;
                ai.SwitchState(msg.self.info.playerSide.state);
                StaticData.fieldData.ResetData(msg.self.info.playerSide);
                UI.UIFieldRunMap.RefreshPage();
                UI.UIFieldRunMap.RefreshTeamInfo();
            }
            else
            {
                var ai = charactor.ai as RCAIActor;
                ai.SwitchState((int)PlayerAIState.Normal);
            }
            roomField.smallMap.miniMapComponent.SetMajorCharactor(charactor.transform);
            
            charactor.ai.SetHp(1f);
            roomField.RoomLoadEnd();
            CheckResOrMonster();//重连后检查一遍资源
            ManagerController.Instance._CompleteTownToField();

        }
        #endregion

       

        public override void SendCSCurrentPosition(object sender)
        {
            CSCurrentPosition msg = new CSCurrentPosition();
            msg.showArround = 1;
            //#if UNITY_EDITOR
            //BoxManager.CreatePopupTextBox("CSCurrentPosition");
            Debug.Log("<color=yellow> CSCurrentPosition </color>");
            //#endif
            NetAPI.SendSocket(OpDefine.CSCurrentPosition, msg);

            NetAPI.SendSocket(OpDefine.CSSceneChatCache, new CSSceneChatCache());
        }

        protected override void SCPlayerAppear(object obj)
        {
            base.SCPlayerAppear(obj);
            
            var msg = (SCPlayerAppear)obj;
            foreach (MovePlayer player in msg.player)
            {
                if (player.info == null || player.position == null) continue;

                StaticData.playerInfos[player.info.playerId] = player;
            }
        }

        protected override void SCPlayerDisappear(object obj)
        {
            base.SCPlayerDisappear(obj);

            var msg = (SCPlayerDisappear)obj;
            foreach (var playerId in msg.playerId)
            {
                if (StaticData.playerInfos.ContainsKey(playerId))
                {
                    StaticData.playerInfos.Remove(playerId);
                }
            }
        }

        protected override void SolveRoleAppear(MovePlayer player)
        {
            base.SolveRoleAppear(player);

            var charactor = roomBase.charactorManager.GetCharactor(player.info.playerId.ToString());
            if (charactor != null)
            {
                charactor.ai.SetHp((float)player.info.playerSide.curHp);
                //charactor.lod.ShowLifeUtil();
                charactor.ui.CreateBoxCollider();
                charactor.ui.CreateRigidbody();
                var ai = charactor.ai as RCAIActor;
                ai.SwitchState(player.info.playerSide.state);
            }
            
            if(StaticData.playerData.team!=null )
            {
                foreach (var member in StaticData.playerData.team.memberList)
                {
                    if (member.playerId == player.info.playerId)
                    {
                        SendCSQueryTeamTick();
                        break;
                    }
                }
            }
        }

        protected override void SolveRoleInfo(MovePlayer info)
        {
            base.SolveRoleInfo(info);
            var charactor = roomBase.charactorManager.GetCharactor(info.info.playerId.ToString());
            if (charactor != null)
            {
                charactor.ai.SetHp((float)info.info.playerSide.curHp);
                //charactor.lod.ShowLifeUtil();
                charactor.ui.CreateBoxCollider();
                charactor.ui.CreateRigidbody();

                if (!StaticData.playerInfos.ContainsKey(info.info.playerId))
                {
                    StaticData.playerInfos[info.info.playerId] = info;
                }

                var ai = charactor.ai as RCAIActor;
                ai.SwitchState(info.info.playerSide.state);
            }
        }
        
        //protected override void SCSceneChatCache(object obj)
        //{
        //    SCSceneChatCache msg = obj as SCSceneChatCache;
        //    Chat.ChatManager.Instance.ReceiveChat(msg.chatList);
        //}


        void SCPingTcp(object msg)
        {
            UI.UIFieldRunMap.SetSpeed(msg);
        }
        
        void SCFieldResourceInfo(object obj)
        {
            var msg = (SCFieldResourceInfo)obj;
            
            foreach (var res in msg.resource)
            {
                if (res.refreshTime <= 0)
                {
                    resAppearQueue.Enqueue(res);
                }
                else
                {
                    resDisppearQueue.Enqueue(res);
                }
            }
        }

        void SCFieldGetResource(object obj)
        {
            SCFieldGetResource msg = (SCFieldGetResource)obj;
            var state = (FieldStateCode)msg.code;
            if (state == FieldStateCode.Success)
            {
                var cost = msg.cost;
                var get = msg.res;
                if (get != null)
                {
                    UI.UIFieldRunMap.DisplayGetResource(get);
                    StaticData.playerData.Delete(cost);
                    UI.UIFieldRunMap.RefreshPage();
                }
            }
            else if (state == FieldStateCode.NotExist)
            {
                BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_res_not_exist"));
                SolveResourceNotExist();
            }
            else
            {
                //BoxManager.CreatePopupTextBox("error state:" + state);
            }
        }

        void SCFieldPlayerState(object obj)
        {
            var msg = (SCFieldPlayerState)obj;
            foreach(var side in msg.player)
            {
                playerSideQueue.Enqueue(side);
            }
        }

        void SCFieldResourceStartGather(object obj)
        {
            var msg = (SCFieldResourceStartGather)obj;
            if (msg!=null)
            {
                var state = (FieldStateCode)msg.result;
                
                if (state == FieldStateCode.Success)
                {
                    if (msg.need.Count > 0)
                        StaticData.tirednessCost = msg.need[0].num;
                    if (roomBase.charactorManager != null && roomBase.charactorManager.GetSelfCharactor() != null)
                    {
                        var actor = roomBase.charactorManager.GetSelfCharactor().ai as RCAIActor;
                        if (actor != null)
                        {
                            bool fish = StaticData.resId.StartsWith("group_fish_");
                            if (fish)
                            {
                                actor.SwitchState(PlayerAIState.Fishing);
                            }
                            else
                            {
                                actor.SwitchState(PlayerAIState.Mining);
                            }

                            UI.UIFieldRunMap.OpenGetResourceWaiting(() =>
                            {
                                var res0 = new CSFieldGetResource();
                                actor.SwitchState(PlayerAIState.Normal);
                                NetAPI.SendSocket(OpDefine.CSFieldGetResource, res0);
                                UI.UIFieldRunMap.RefreshPage();
                            });
                        }
                    }
                }
                else if (state == FieldStateCode.NotExist)
                {
                    BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_res_not_exist"));
                    SolveResourceNotExist();
                }
               
            }
        }

        void SCGetLineInfo(object obj)
        {
            var msg = (SCGetLineInfo)obj;
            if (msg.lineInfos != null)
            {
                StaticData.lineInfo = msg;
                StaticData.lineInfos.AddRange(msg.lineInfos);
                //Debug.Log("<color=yellow>"+StaticData.lineInfos.Count+"</color>");
                StaticData.currLine = msg.line;
                UI.UIFieldRunMap.RefreshLineInfo();
            }
        }

        void SCSidePushState(object obj)
        {
            var msg = (SCSidePushState)obj;
           
            foreach (var state in msg.states)
            {
                var charactor = roomBase.charactorManager.GetCharactor(state.playerId.ToString());
                if (charactor != null)
                {
                    charactor.SetKillNum(state.kills);
                    charactor.ai.SetHp((float)state.hp);
                    var ai = charactor.ai as RCAIActor;
                    ai.SwitchState(state.state);
                }
                

                if (StaticData.playerInfos.ContainsKey(state.playerId))
                {
                    if (StaticData.playerInfos[state.playerId].info != null &&
                        StaticData.playerInfos[state.playerId].info.playerSide != null)
                        StaticData.playerInfos[state.playerId].info.playerSide.curHp = state.hp;
#if UNITY_EDITOR
                    //Debug.LogError("[Update PlayerSide Info]: playerId:" + playerSide.playerId + " currentHp;" + playerSide.curHp);
#endif
                }

                //对自己的处理
                if (state.playerId == StaticData.playerData.playerId)
                {
                    StaticData.fieldData.currentHp = (float)state.hp;
                    StaticData.fieldData.kills = state.kills;
                    StaticData.fieldData.Anger = (float)state.anger;
                    
                    UI.UIFieldRunMap.RefreshPage();
                }

                //朝向问题
                SolveFaceToTarget(state.playerId + "", state.target);



#if UNITY_EDITOR
                Debug.Log("<color=green>[收到服务器状态] state [" + state.state + "] "+ state.state + "["+ state.playerId+ "]"+" killers:"+state.kills+ "[协议:SCSidePushState]" + "</color>");
                //BoxManager.CreatePopupTextBox("[SCSidePushState] playerId:" + state.playerId + " state:" + (PlayerAIState)state.state+" hp:"+state.hp);
#endif
            }
        }

        /// <summary>
        /// 复活
        /// </summary>
        /// <param name="obj"></param>
        void SCResurrenttion(object obj)
        {
            var reborn = (SCResurrenttion)obj;
            var actor = roomBase.charactorManager.GetSelfCharactor().ai as RCAIActor;
            if (actor != null)
            {
                actor.SwitchState(reborn.state.state);
                actor.SetKillNum(reborn.state.kills);
                actor.SetHp((float)reborn.state.hp);

                var state = actor.GetCurrState() as PlayerAIStateNormal;
                state.InvincibleTimer = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.InvincibleTime;
                state.PlayReborn();

                StaticData.fieldData.currentHp = (float)reborn.state.hp;
                StaticData.fieldData.Anger = (float)reborn.state.anger;
                StaticData.fieldData.kills = reborn.state.kills;
                
                UI.UIFieldRunMap.RefreshPage();
            }
            else
            {
                SendCSCurrentPosition(null);
            }
            StaticData.playerData.Delete(reborn.cost);
            UI.UIFieldRunMap.RefreshPage();
        }
        /// <summary>
        /// 安全区复活
        /// </summary>
        /// <param name="obj"></param>
        void SCTransfer2Safe(object obj)
        {
            var reborn = (SCTransfer2Safe)obj;
            var state = (FieldStateCode)reborn.result;
            if(state == FieldStateCode.Success)
            {
                var actor = roomBase.charactorManager.GetSelfCharactor().ai as RCAIActor;
                actor.SwitchState(PlayerAIState.Normal);
                var st = actor.GetCurrState() as PlayerAIStateNormal;
                st.InvincibleTimer = 3f;
                SendCSCurrentPosition(null);
            }
            else
            {
                //BoxManager.CreatePopupTextBox("error state:" + state);
            }

        }

        /// <summary>
        /// 切线
        /// </summary>
        /// <param name="obj"></param>
        void SCTransferLine(object obj)
        {

            //var line = (SCTransferLine)obj;
            

            CSCurrentPosition msg = new CSCurrentPosition();
#if UNITY_EDITOR
            //BoxManager.CreatePopupTextBox("CSCurrentPosition");
            Debug.Log("<color=yellow> CSCurrentPosition </color>");
#endif
            msg.line = StaticData.currLine;

            List<string> willDelete = new List<string>();
            foreach(var charactor in roomBase.charactorManager.GetCharactors())
            {
                if(charactor.Value.type == CharactorType.Mine ||
                    charactor.Value.type == CharactorType.Fish ||
                    charactor.Value.type == CharactorType.ServerMonster ||
                    charactor.Value.type == CharactorType.OtherPlayer||
                    charactor.Value.type == CharactorType.FieldBoss)
                {
                    willDelete.Add(charactor.Key);
                }
            }
            
            foreach(var uuid in willDelete)
            {
                roomBase.charactorManager.DestroyCharactor(uuid);
            }
            

            StaticData.ClearFieldCache();

            NetAPI.SendSocket(OpDefine.CSCurrentPosition, msg);

            NetAPI.RegistSocketHandler(OpDefine.SCSceneChatCache, (pack) =>
            {
                SCSceneChatCache scs = pack as SCSceneChatCache;
                Chat.ChatManager.Instance.ReceiveChat(scs.chatList);
            });
            NetAPI.SendSocket(OpDefine.CSSceneChatCache, new CSSceneChatCache());
        }
        

        /// <summary>
        /// 检查资源问题
        /// </summary>
        /// <param name="obj"></param>
        void SCSideResourceCheck(object obj)
        {
            SCSideResourceCheck msg = (SCSideResourceCheck)obj;
            if((FieldStateCode)msg.code == FieldStateCode.NotExist)
            {
                string str = msg.resourceId + "@" + msg.posId;

                roomBase.charactorManager.DestroyCharactor(str);
                
                if(StaticData.fieldRes.ContainsKey(str))
                {
                    StaticData.fieldRes.Remove(str);
                }
            }
            else
            {
                List<string> delRes = new List<string>();
                foreach(var _res in roomBase.charactorManager.GetCharactors())
                {
                    if (_res.Value != null && (_res.Value.type == CharactorType.Mine || _res.Value.type == CharactorType.Fish))
                    {
                        var id = _res.Key;
                        if (id.Contains("@"))
                        {
                            var sss = id.Split(new char[1] { '@' }, System.StringSplitOptions.RemoveEmptyEntries);
                            if (sss[1] == msg.posId && sss[0] != msg.resourceId)
                            {
                                delRes.Add(id);
                            }
                        }
                    }
                }

                foreach(var id0 in delRes)
                {
                    roomBase.charactorManager.DestroyCharactor(id0);
                }
            }
        }

        /// <summary>
        /// 战斗消息
        /// </summary>
        /// <param name="obj"></param>
        void SCSidePvpFightResult(object obj)
        {
            var msg = (SCSidePvpFightResult)obj;
            var state = (FieldStateCode)msg.code;
            if (state == FieldStateCode.Success)
            {
                UI.UIFieldRunMap.BattleReady(msg, () => 
                {
                    
                    //自己是攻击者
                    if (msg.attPlayerId == StaticData.playerData.playerId && 
                    msg.winPlayerId == StaticData.playerData.playerId)
                    {
                        StaticData.playerData.AddResultObj(msg.result);
                        StaticData.playerData.Delete(msg.cost);
                    }
                    else if(msg.defPlayerId == StaticData.playerData.playerId && 
                    msg.winPlayerId == msg.attPlayerId)
                    {
                        StaticData.playerData.Delete(msg.looted);
                        StaticData.playerData.Delete(msg.cost);
                    }
                    
                    var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
                    if(page!=null)
                    {
                        page.battleRedTip.SetActive(true);
                        page.Refresh();
                    }
                });
            }
            else if (state == FieldStateCode.PlayerInBattle)
            {
                BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_player_in_battle"));
            }
            else if (state == FieldStateCode.DistanceTooFar)
            {
                BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_player_dis_far"));
            }
            else if(state == FieldStateCode.PlayerInSafe)
            {
                BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_player_in_safe"));
            }
            else
            {
                //BoxManager.CreatePopupTextBox("error state:" + state);
            }
        }

        void SCSideMonster(object obj)
        {
            var msg = (SCSideMonster)obj;
            foreach (var monster in msg.monsters)
            {
                var state = monster.state;
                if (!StaticData.fieldMon.ContainsKey(monster.uuid))
                {
                    if (state != ServerMonsterAIState.Death && state!=ServerMonsterAIState.None)
                    {
                        roomBase.charactorManager.CreateMonster(monster);
                        var mon = roomBase.charactorManager.GetCharactor(monster.uuid);

                        var stopTo = new Vector3(monster.currentPoint.x, monster.currentPoint.y, monster.currentPoint.z);
                        roomBase.charactorManager.SetPosition(monster.uuid, stopTo);

                        mon.ai.SetHp((float)monster.curHp);
                        mon.ui.CreateBoxCollider();
                        mon.ui.CreateRigidbody();
                    }
                }

                StaticData.fieldMon[monster.uuid] = monster;
            }
            List<string> deathList = new List<string>();
            foreach (var kvp in StaticData.fieldMon)//切怪的状态
            {
                var monster = kvp.Value;
                var charactor = roomBase.charactorManager.GetCharactor(monster.uuid);
                if (charactor != null)
                {
                    var ai = charactor.ai as RCAIServerMonster;
                    ai.SwitchState(monster.state);
                    if (monster.state == ServerMonsterAIState.Death)
                    {
                        deathList.Add(monster.uuid);
                    }
                    ai.Init(monster);
                    ai.SetHp((float)monster.curHp);

                    if (monster.state != ServerMonsterAIState.Death)
                    {
                        var stopTo = new Vector3(monster.currentPoint.x, monster.currentPoint.y, monster.currentPoint.z);
                        roomBase.charactorManager.StopTo(monster.uuid, stopTo);
                    }
                }
            }

            foreach(var id in deathList)
            {
                roomBase.charactorManager.DestroyCharactor(id);
                StaticData.fieldMon.Remove(id);
            }
        }

        void SCSideMonsterCheck(object obj)
        {
            var msg = (SCSideMonsterCheck)obj;
            if((FieldStateCode)msg.code == FieldStateCode.NotExist)
            {
                var monster = roomBase.charactorManager.GetCharactor(msg.monster.uuid);
                if(monster!=null)
                {
                    roomBase.charactorManager.DestroyCharactor(msg.monster.uuid);
                }
                if(StaticData.fieldMon.ContainsKey(msg.monster.uuid+""))
                {
                    StaticData.fieldMon.Remove(msg.monster.uuid + "");
                }
            }
        }

        void SCSidePveFightStart(object obj)
        {
            var msg = (SCSidePveFightStart)obj;
            if ((FieldStateCode)msg.code == FieldStateCode.Success)
            {
                if (msg != null && msg.battlePlayer != null && msg.battleMonsterList.Count > 0)
                {
                    StaticData.curBattleData.SetData(msg);
                    ManagerController.Instance.FieldToBattle();
                }
            }
            else if ((FieldStateCode)msg.code == FieldStateCode.NotExist)
            {
                if (StaticData.currClickMonster != null)
                {
                    SolveMonsterNotExist(StaticData.currClickMonster);
                }
            }
        }
        
        void SCSideBoss(object obj)
        {
            SCSideBoss msg = (SCSideBoss)obj;
            List<string> deathList = new List<string>();
            foreach (var boss in msg.monsters)
            {
                if (boss.currentPoint == null) continue;

                var state = (FieldBossAIState)boss.state;
                if (state == FieldBossAIState.Normal)
                {
                    var charactor = roomBase.charactorManager.GetCharactor(boss.uuid);
                    if (charactor != null)
                    {
                        var ai = charactor.ai as RCAIFieldBoss;
                        ai.SwitchState(FieldBossAIState.Normal);
                        ai.SetHp((float)boss.curHp);
                        ai.SetKillNum(0);
                    }
                    else
                    {
                        roomBase.charactorManager.CreateFieldBoss(boss);
                        charactor = roomBase.charactorManager.GetCharactor(boss.uuid);
                        var ai = charactor.ai as RCAIFieldBoss;
                        ai.SwitchState(FieldBossAIState.Normal);
                        ai.SetHp((float)boss.curHp);
                        ai.SetKillNum(0);
                        var ui = charactor.ui as RCUIFieldBoss;
                        ui.CreateBoxCollider();
                    }
                }
                else
                {
                    var charactor = roomBase.charactorManager.GetCharactor(boss.uuid);
                    if (charactor != null)
                    {
                        var ai = charactor.ai as RCAIFieldBoss;
                        ai.SwitchState(FieldBossAIState.Death);
                        deathList.Add(boss.uuid);
                    }
                }

            }

            foreach(var it in deathList)
            {
                roomBase.charactorManager.DestroyCharactor(it);
            }
        }


        void SCSideBossCheck(object obj)
        {
            SCSideBossCheck msg = (SCSideBossCheck)obj;
            if ((FieldStateCode)msg.code == FieldStateCode.NotExist)
            {
                 roomBase.charactorManager.DestroyCharactor(msg.monster.uuid);
                
                if (StaticData.fieldBoss.ContainsKey(msg.monster.uuid + ""))
                {
                    StaticData.fieldBoss.Remove(msg.monster.uuid + "");
                }
            }
        }

        void SCSidePveBossFightStart(object obj)
        {
            SCSidePveBossFightStart msg = (SCSidePveBossFightStart)obj;
            if ((FieldStateCode)msg.code == FieldStateCode.Success)
            {
                StaticData.curBattleData.SetData(msg);
                ManagerController.Instance.FieldToBattle();
            }
            else if ((FieldStateCode)msg.code == FieldStateCode.NotExist)
            {
                if (StaticData.currClickBoss != null)
                {
                    SolveBossNotExist(StaticData.currClickBoss);
                }
            }
        }

        void SCSideBossCountdown(object obj)
        {
            var msg = (SCSideBossCountdown)obj;
            
            UI.UIFieldRunMap.RefreshBossTime(msg.time);
        }

        #region 组队
        void SCTeamCreateAndInvite(object obj)
        {
            var msg = obj as SCTeamCreateAndInvite;

            if (msg.team.memberList[0].playerId == StaticData.playerData.playerId)
            {
                StaticData.playerData.team = msg.team;
                StaticData.playerData.teamId = msg.team.teamId;
            }
            if (msg.invitePlayerId != StaticData.playerData.playerId)
            {
                var memberName = "";
                foreach (var member in msg.team.memberList)
                {
                    if (member.playerId == msg.invitePlayerId)
                    {
                        memberName = member.nickName;
                        break;
                    }
                }


                var str = string.Format(TableTextBlo.GetText("field_team_ask"), memberName);
                BoxManager.CreateMessageBoxWithCofirmAndCancelButton(str, true, (b) =>
                {
                    if (b)
                    {
                        SendCSJoinTeam(msg.team.teamId);
                    }
                },TableTextBlo.GetText("field_team_accept"));
            }

            //UI.UIFieldRunMap.RefreshPage();
            UI.UIFieldRunMap.RefreshTeamInfo();
        }

        void SCQueryTeam(object obj)
        {
            SCQueryTeam que = obj as SCQueryTeam;
            if (que != null)
            {
                StaticData.playerData.team = que.team;
            }

            UI.UIFieldRunMap.RefreshTeamInfo();
            var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
            if(page!=null)
            {
                page.teamPanel.Init();
            }
        }

        void SCJoinTeam(object obj)
        {
#if UNITY_EDITOR
            Debug.Log("[DEBUG] 收到加入小队信息");
#endif
            SCJoinTeam join = obj as SCJoinTeam;
            if (join != null && join.team != null)
            {
                StaticData.playerData.team = join.team;
                StaticData.playerData.teamId = join.team.teamId;
            }

            if (StaticData.playerData.playerId == join.toPlayerId)
            {
                BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_team_join_succ"));
            }
            else
            {
                foreach (var m in StaticData.playerData.team.memberList)
                {
                    if (m.playerId == join.toPlayerId)
                    {
                        BoxManager.CreatePopupTextBox(string.Format(TableTextBlo.GetText("field_new_member_add"),m.nickName));
                        break;
                    }
                }
            }
            
            UI.UIFieldRunMap.RefreshTeamInfo();
            var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
            if (page != null && page.teamPanel.gameObject.activeSelf)
            {
                page.teamPanel.Refresh(join.team);
            }
        }

        void SCExitTeam(object obj)
        {
#if UNITY_EDITOR
            Debug.Log("[DEBUG] 收到退出小队信息");
#endif
            SCExitTeam exit = obj as SCExitTeam;
            if (exit != null && exit.team != null)
            {
                StaticData.playerData.team = exit.team;
                bool exitMe = true;
                foreach(var member in exit.team.memberList)
                {
                    if(member.playerId == StaticData.playerData.playerId)
                    {
                        exitMe = false;
                        break;
                    }
                }

                if (exitMe && exit.team.teamId == StaticData.playerData.teamId)
                {
                    StaticData.playerData.team = null;
                    StaticData.playerData.teamId = "";
                    if (exit.member.playerId == StaticData.playerData.playerId)
                        BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_team_exit_suc"));
                    else
                        BoxManager.CreatePopupTextBox(string.Format(TableTextBlo.GetText("field_exit_team_suc"), exit.member.nickName)); 
                }
            }

            UI.UIFieldRunMap.RefreshTeamInfo();
            var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
            if (page != null && page.teamPanel.gameObject.activeSelf)
            {
                page.teamPanel.Refresh(StaticData.playerData.team);
            }
        }

        void SCDisbandTeam(object obj)
        {
#if UNITY_EDITOR
            Debug.Log("[DEBUG] 收到解散小队信息");
#endif
            SCDisbandTeam dis = obj as SCDisbandTeam;
            if (dis != null)
            {
                if (dis.teamId == StaticData.playerData.teamId)
                {
                    StaticData.playerData.team = null;
                    StaticData.playerData.teamId = "";

                    BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_team_force_dismiss"));
                }
            }
            
            UI.UIFieldRunMap.RefreshTeamInfo();
            var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
            if (page != null && page.teamPanel.gameObject.activeSelf)
            {
                page.teamPanel.Refresh(StaticData.playerData.team);
            }
        }

        void SCTeamKick(object obj)
        {
#if UNITY_EDITOR
            Debug.Log("[DEBUG] 收到剔出小队信息");
#endif
            SCTeamKick kick = obj as SCTeamKick;
            if(kick!=null && kick.team!=null)
            {
                StaticData.playerData.team = kick.team;

                bool kickMe = true;
                foreach (var member in kick.team.memberList)
                {
                    if (member.playerId == StaticData.playerData.playerId)
                    {
                        kickMe = false;
                        break;
                    }
                }

                if ( kickMe && kick.team.teamId == StaticData.playerData.teamId)
                {
                    StaticData.playerData.teamId = "";
                    StaticData.playerData.team = null;

                    BoxManager.CreatePopupTextBox(TableTextBlo.GetText("field_force_leave_team"));
                    UI.UIFieldRunMap.RefreshPage();
                    var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
                    if (page != null && page.teamPanel.gameObject.activeSelf)
                    {
                        page.teamPanel.gameObject.SetActive(false);
                    }
                }
                else
                {
                    BoxManager.CreatePopupTextBox(string.Format(TableTextBlo.GetText("field_kick_team_suc"), kick.member.nickName));
                    var page = UI.PageManager.Instance.currentPage as UI.UIFieldRunMap;
                    if (page != null && page.teamPanel.gameObject.activeSelf)
                    {
                        page.teamPanel.Refresh(kick.team);
                    }
                }
            }
            UI.UIFieldRunMap.RefreshTeamInfo();
        }

        void SCCheckTeam(object obj)
        {
            //var check = obj as SCCheckTeam;
            //UI.UIFieldAskPk.hasTeamFlag = check.checkResult == BOOL.TRUE;
        }

        void SCQueryTeamTick(object obj)
        {
            var tick = obj as SCQueryTeamTick;

            if (StaticData.playerData.team == null)
            {
                StaticData.playerData.team = tick.team;
            }
            else if(tick.team!=null)
            {
                foreach(var member in StaticData.playerData.team.memberList)
                {
                    foreach (var memberInner in tick.team.memberList)
                    {
                        if(member.playerId == memberInner.playerId)
                        {
                            member.curHp = memberInner.curHp;
                            member.state = memberInner.state;
                            break;
                        }
                    }
                }
            }
            StaticData.playerData.teamId = tick.team.teamId;
            UI.UIFieldRunMapTeamInfo.forceUpdate = true;
            UI.UIFieldRunMapTeamInfo.updateTime = tick.seconds <= 0 ? 3 : tick.seconds;
            Debug.Log("[DEBUG] server give update timer:" + tick.seconds);
        }

        #endregion

        #region Sender
        /// <summary>
        /// 发送当前操作的资源
        /// </summary>
        /// <param name="id"></param>
        /// <param name="posId"></param>
        public void SendGetFieldRes(string id, string posId)
        {
            var dictCost = Dict.Blo.DictFieldResourceBlo.GetCost(id);
            var intCost = dictCost["tiredness"];
            //if (intCost <= StaticData.playerData.Tiredness  )
            //{

                var msg = new CSFieldResourceStartGather();
                msg.posId = posId;
                StaticData.resPosId = posId;
                StaticData.resId = id;

                NetAPI.SendSocket(OpDefine.CSFieldResourceStartGather, msg);
            //}
            //else
            //{
            //    BoxManager.CreatePopupTextBox(TableTextBlo.GetText("tiredness_not_enough"));
            //}
        }

        /// <summary>
        /// 发送资源check
        /// </summary>
        /// <param name="posId"></param>
        public void SendResourceCheck(string posId)
        {
            CSSideResourceCheck check = new CSSideResourceCheck();
            check.posId = posId;
            NetAPI.SendSocket(OpDefine.CSSideResourceCheck, check);
            Debug.Log("[CHECK RES] posId:" + posId);
        }

        public void SendFightPvp(long playerId,string tipStr)
        {
            if (string.IsNullOrEmpty(tipStr) && 
                StaticData.fieldData.kills >= Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.MaxKillLimit)
            {
                tipStr = TableTextBlo.GetText("max_kill_player");
            }
            
            var safeArea = roomBase.charactorManager.GetCharactor(StaticData.fieldId);
            var beHitPlayer = roomBase.charactorManager.GetCharactor(playerId.ToString());

            if (string.IsNullOrEmpty(tipStr) && beHitPlayer == null)
            {
               tipStr = TableTextBlo.GetText("field_player_offline");
            }

            var ai = safeArea.ai as RCAISafeArea;

            if (string.IsNullOrEmpty(tipStr) && ai.CheckInSafeArea(beHitPlayer))
            {
                tipStr = TableTextBlo.GetText("field_safe_area");
            }
            
            AskPvp(playerId,tipStr);
        }

        public void SendCheckPveMonster(string uuid)
        {
            CSSideMonsterCheck chk = new CSSideMonsterCheck();
            chk.uuid = uuid;
            NetAPI.SendSocket(OpDefine.CSSideMonsterCheck, chk);
            Debug.Log("[CHECK PVE MONSTER] uuid:" + uuid);
        }

        public void SendCheckPveBoss(string uuid)
        {
            CSSideBossCheck chk = new CSSideBossCheck();
            chk.uuid = uuid;
            NetAPI.SendSocket(OpDefine.CSSideBossCheck, chk);
            Debug.Log("[CHECK PVE BOSS] uuid:" + uuid);
        }

        public void SendPve(string uuid)
        {
            CSSidePveFightStart pve = new CSSidePveFightStart();
            pve.monsterId = uuid;
            NetAPI.SendSocket(OpDefine.CSSidePveFightStart, pve);
            
        }

        public void SendPveBoss(string uuid)
        {
            CSSidePveBossFightStart bos = new CSSidePveBossFightStart();
            bos.uuid = uuid;
            StaticData.pveBossUUID = uuid;
            NetAPI.SendSocket(OpDefine.CSSidePveBossFightStart, bos);
        }
        void AskPvp(long playerId,string tipStr)
        {
            MovePlayer data = null;
            if (StaticData.playerInfos.ContainsKey(playerId))
            {
                data = StaticData.playerInfos[playerId];
                UI.UIFieldRunMap.AskPk(data, (arress) =>
                 {
                     var res = new CSSidePvpFightResult();
                     res.playerId = playerId;
                     res.fightType = arress ? 1 : 0;
                     res.appVersion = GameConfig.Instance.AppVersion;
                     res.resVersion = GameConfig.Instance.ResVersion;
                     NetAPI.SendSocket(OpDefine.CSSidePvpFightResult, res);
                     //Debug.Log(StaticData.playerInfos.Count);
                 }, tipStr);
            }
        }

        /// <summary>
        /// 发送砖石复活
        /// </summary>
        public void SendReborn()
        {
            CSResurrection msg = new CSResurrection();
            NetAPI.SendSocket(OpDefine.CSResurrection, msg);
        }

        /// <summary>
        /// 安全区复活
        /// </summary>
        public void SendSafeAreaReborn()
        {
            CSTransfer2Safe msg = new CSTransfer2Safe();
            NetAPI.SendSocket(OpDefine.CSTransfer2Safe, msg);
        }

        /// <summary>
        /// 换线
        /// </summary>
        public void SendTransferLine(int line)
        {
            CSTransferLine trLine = new CSTransferLine();
            trLine.line = line;
            NetAPI.SendSocket(OpDefine.CSTransferLine, trLine);
        }

        /// <summary>
        /// 获取线的信息
        /// </summary>
        public void SendGetLineInfo()
        {
            CSGetLineInfo info = new CSGetLineInfo();
            NetAPI.SendSocket(OpDefine.CSGetLineInfo, info);
        }

        #region 组队
        public void SendCSTeamCreateAndInvite(long playerId,int serverId)
        {
            CSTeamCreateAndInvite msg = new CSTeamCreateAndInvite();
            msg.invitePlayerIdList.Add(playerId);
            msg.inviteServerIdList.Add(serverId);
            NetAPI.SendSocket(OpDefine.CSTeamCreateAndInvite, msg);
        }
        public void SendCSQueryTeam()
        {
            CSQueryTeam que = new CSQueryTeam();
            que.teamId = StaticData.playerData.teamId;
            NetAPI.SendSocket(OpDefine.CSQueryTeam, que);
        }
        public void SendCSJoinTeam(string teamId)
        {
            CSJoinTeam join = new CSJoinTeam();
            join.teamId = teamId;
            NetAPI.SendSocket(OpDefine.CSJoinTeam, join);
        }
        public void SendCSExitTeam()
        {
            CSExitTeam exit = new CSExitTeam();
            exit.teamId = StaticData.playerData.teamId;
            NetAPI.SendSocket(OpDefine.CSExitTeam, exit);
        }

        public void SendCSQueryTeamTick()
        {
            CSQueryTeamTick tick = new CSQueryTeamTick();
            NetAPI.SendSocket(OpDefine.CSQueryTeamTick, tick);
        }
        public void SendCSDisbandTeam()
        {
            CSDisbandTeam dis = new CSDisbandTeam();
            dis.teamId = StaticData.playerData.teamId;
            NetAPI.SendSocket(OpDefine.CSDisbandTeam, dis);
        }

        public void SendCSTeamKick(long playerID)
        {
            CSTeamKick kick = new CSTeamKick();
            kick.treamId = StaticData.playerData.teamId;
            kick.toPlayerId = playerID;
            NetAPI.SendSocket(OpDefine.CSTeamKick, kick);
        }

        #endregion

        #endregion

        #region Solve
        /// <summary>
        /// 添加资源信息
        /// </summary>
        /// <param name="res"></param>
        void SolveAddResource(SideResource res)
        {
            //确保同一个位置上只有一个矿或者鱼
            List<string> ls = new List<string>();
            foreach(var charactor in roomBase.charactorManager.GetCharactors())
            {
                if (charactor.Value != null && 
                    (charactor.Value.type == CharactorType.Mine || charactor.Value.type == CharactorType.Fish))
                {
                    if (charactor.Key.Contains("@"))
                    {
                        var sss = charactor.Key.Split(new char[1] { '@' }, System.StringSplitOptions.RemoveEmptyEntries);
                        if (res.posId == sss[1])
                        {
                            ls.Add(charactor.Key);
                        }
                    }
                }
            }

            foreach (var del in ls)
            {
                roomBase.charactorManager.DestroyCharactor(del);
            }
            roomField.charactorManager.CreateResource(res.id,res.posId);
            var str = res.id + "@" + res.posId;
            StaticData.fieldRes[str] = res;

        }

        /// <summary>
        /// 删除资源
        /// </summary>
        /// <param name="res"></param>
        void SolveDisappearResource(SideResource res)
        {
            var resStr = res.id + "@" + res.posId;
            roomField.charactorManager.DestroyCharactor(resStr);
            if(StaticData.fieldRes.ContainsKey(resStr))
            {
                StaticData.fieldRes.Remove(resStr);
            }
        }

        /// <summary>
        /// 更新Player信息
        /// </summary>
        /// <param name="playerSide"></param>
        void SolveUpdateMovePlayer(PlayerSide playerSide)
        {
            var uuid = playerSide.playerId.ToString();
            var player = roomField.charactorManager.GetCharactor(uuid);
            if(player!=null)
            {
                player.SetKillNum(playerSide.kills);
                player.ai.SetHp((float)playerSide.curHp);

                //切状态
                var ai = player.ai as RCAIActor;
                ai.SwitchState(playerSide.state);
                
            }

            if (StaticData.playerData.playerId == playerSide.playerId)
            {
                StaticData.fieldData.ResetData(playerSide);
                UI.UIFieldRunMap.RefreshPage();
               
            }
            

#if UNITY_EDITOR
            Debug.Log("<color=yellow>[DEBUG] state:"+ playerSide.state + playerSide.state+"["+ playerSide.playerId+"]" + "[协议:SCFieldPlayerState]</color>");
           // BoxManager.CreatePopupTextBox("[SCFieldPlayerState] playerId:" + playerSide.playerId + " state:" + (PlayerAIState)playerSide.state);
#endif
        }

        void SolveFaceToTarget(string id0,string target)
        {
            if (string.IsNullOrEmpty(id0) || string.IsNullOrEmpty(target))
                return;

            if (target.StartsWith("fish_pos_") || target.StartsWith("mine_pos_"))
            {
                var person0 = roomBase.charactorManager.GetCharactor(id0);
                if(person0!=null)
                {
                    foreach(var kvp in roomBase.charactorManager.GetCharactors())
                    {
                        if( kvp.Value.type == CharactorType.Mine || 
                            kvp.Value.type == CharactorType.Fish)
                        {
                            var str = kvp.Key;
                            var sss = str.Split(new char[1] { '@' },System.StringSplitOptions.RemoveEmptyEntries);
                            
                            if(sss[1] == target)
                            {
                                var person1 = kvp.Value;
                                person0.transform.LookAt(person1.transform);//人盯着矿就行了，矿不用顶着人
                            }
                        }
                    }
                }
            }
            else//怪或者人了
            {
                var person0 = roomBase.charactorManager.GetCharactor(id0);
                var person1 = roomBase.charactorManager.GetCharactor(target);
                if(person0!=null && person1!=null)
                {
                    person0.transform.LookAt(person1.transform);
                    person1.transform.LookAt(person0.transform);
                }
            }
        }

        protected override void SolveRoleDisappear(long id)
        {
            base.SolveRoleDisappear(id);
            if(StaticData.playerData.team!=null)
            {
                foreach(var member in StaticData.playerData.team.memberList)
                {
                    if(member.playerId == id)
                    {
                        SendCSQueryTeamTick();
                        break;
                    }
                }
            }
        }
        
        #endregion

        #region 不存在处理
        void SolveResourceNotExist()
        {
            string key = StaticData.resId + "@" + StaticData.resPosId;
            roomBase.charactorManager.DestroyCharactor(key);
            if(StaticData.fieldRes.ContainsKey(key))
            {
                StaticData.fieldRes.Remove(key);
            }
            StaticData.resPosId = "";
            StaticData.resId = "";
        }
        
        void SolveMonsterNotExist(SideMonster monster)
        {
            roomBase.charactorManager.DestroyCharactor(monster.uuid);
            if(StaticData.fieldMon.ContainsKey(monster.uuid))
            {
                StaticData.fieldMon.Remove(monster.uuid);
            }
            StaticData.currClickMonster = null;
        }

        void SolveBossNotExist(SideBoss boss)
        {
            roomBase.charactorManager.DestroyCharactor(boss.uuid);
            if (StaticData.fieldBoss.ContainsKey(boss.uuid))
            {
                StaticData.fieldBoss.Remove(boss.uuid);
            }
            StaticData.currClickBoss = null;
        }
        #endregion
    }
}
